#ifndef MAINWIDGET_H
#define MAINWIDGET_H

#include <QWidget>
#include <QDeclarativeView>
#include <QDeclarativeItem>
#include <QDeclarativeContext>
#include "gamedata.h"
#include "gamewindow.h"
#include "screen.h"
#include "menuwindow.h"
#include "levelwindow.h"
#include "instructionview.h"
#include "scoreview.h"

#if defined(Q_OS_SYMBIAN) || defined(Q_WS_MAEMO_5)
const QString contentPath = "qml/cakeTower/";
#else
const QString contentPath = "qml/cakeTower/";
#endif

class MainWidget : public QDeclarativeView
{
    Q_OBJECT

public:
    MainWidget(QWidget *parent=0);
    ~MainWidget();
    void create();
    void update(float deltatime);
    void pause();
    void resume();
    unsigned int getTickCount() const;
    Q_INVOKABLE void setScreen(int i);
    float getFrameTime() const;
    float getFPS() const;
    void timerEvent(QTimerEvent *event);
    void render();
    void deleteScreen(int scr);
    Q_INVOKABLE bool getSoundMute();
    Q_INVOKABLE void setSoundMute(bool isMute);
    Q_INVOKABLE bool getMusicMute();
    Q_INVOKABLE void setMusicMute(bool isMute);
    Q_INVOKABLE int getScore();
    Q_INVOKABLE void setScore(int score);

public slots:
    void minimizeWindow();
    void exitApplication();

private:
    // Time calculation
    unsigned int m_prevTime;
    unsigned int m_currentTime;
    float m_frameTime;
    float m_fps;
    bool m_paused;
    int m_timerId;

    bool isUpdatable;
    bool isHideScreen;
    bool isSoundMute;
    bool isMusicMute;
    int myScore;
    int prevScreen;
    int currScreen;

    QDeclarativeContext *m_context;
    QObject *viewScreen;
    QTimer *m_gameTimer;
    GameData m_gameData;
    GameWindow *myGameWindow;
    Screen *myScreen;


};

#endif // MAINWIDGET_H
